package com.yy.web.pm.alarm.controller;

import com.yy.web.pm.alarm.alarmDto.AlarmDtoList;
import com.yy.web.pm.alarm.domain.AlarmDate;
import com.yy.web.pm.alarm.service.AlarmDateService;
import com.yy.web.pm.billboard.domain.Dto.BillboardDto;
import com.yy.web.pm.billboard.service.BillboardDataService;
import com.yy.web.pm.until.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: AlarmController
 * @Description: 类描述:告警数据管理员进行处理
 * @date: 2025/4/16
 */

@RestController
@RequestMapping("/alarm")
public class AlarmController {
    @Qualifier("alarmDateServiceImpl")
    @Autowired
    private AlarmDateService alarmService;
    @Autowired
    private BillboardDataService billboardDataService;

    //告警列表(管理员)
    @GetMapping("/list")
    public Result getAlarmList(AlarmDtoList alarmDate) {
        return Result.success(alarmService.selectAlarmAllDate(alarmDate));
    }

    // 商家信息列表
    @GetMapping("/shopList")
    public Result getShopList(BillboardDto alarmDate) {
        return Result.success(alarmService.selectShopAllDate(alarmDate));
    }


    //  管理员审核判断数据是否是真实报警，真实报警则派发，否则则取消报警，关闭工单，记录存档
    @PostMapping("/examine")
    public Result AdminUpdateExamine(@RequestBody AlarmDate alarmDate, Authentication authentication) {
        String openid = authentication.getName();
        return Result.success(alarmService.AdminUpdateExamine(alarmDate,openid));
    }


    // 商家广告牌修改列表
    @GetMapping("/adList")
    public Result getAdList(@RequestBody BillboardDto billboardDto) {
        return Result.success(alarmService.ShopUpdateAllList(billboardDto));
    }

    //管理员审批商家上交的广告牌变更
    @PostMapping("/examineAd")
    public Result AdminUpdateExamineAd(@RequestBody BillboardDto billboardDto) {
        return Result.success(alarmService.selectBillBoardList(billboardDto));
    }

    //管理员查看广告牌到期时间接口
    @GetMapping("/adListTime")
    public Result getAdListTime(@RequestBody BillboardDto billboardDto) {
        return Result.success(billboardDataService.SelectBillBoardExpire(billboardDto));
    }

    //管理员审处理广告牌到期接口
    @PostMapping("/examineAdTime")
    public Result AdminUpdateExamineAdTime(@RequestBody BillboardDto billboardDto) {
        alarmService.AdminUpdateExamineAdTime(billboardDto);
        return Result.success("成功");
    }

    //管理员下发Ridf标签
    @PostMapping("/examineAdRfid")
    public Result AdminUpdateExamineAdRfid(@RequestParam Long id) {
        return Result.success(billboardDataService.updateDate(id));

    }
}
